package com.wondersgroup.fjzlpt.org.dao.impl.jgqy.qysq;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.repository.sql.bean.SQLBean;
import com.quick.framework.boot.repository.sql.bean.table.TableBean;
import com.quick.framework.boot.repository.sql.jdbcTemplate.impl.BaseJTDAOImpl;
import com.wondersgroup.fjzlpt.org.dao.inter.jgqy.qysq.QysqYljgDAO;
@Repository
public class QysqGlDAOImpl extends BaseJTDAOImpl implements QysqYljgDAO{
	@Override
	@Autowired
	@Qualifier("TB_JGQY_YLT_YLJG")
	public void setTb(TableBean tb) {
		super.setTb(tb);
	}


	/**
	 * 根据医联体id删除记录 
	 * @param map
	 */
	public void delete(Map<String, String> map) {
		StringBuffer sbuf = new StringBuffer();
		sbuf.append("delete from "+this.tb.getTableName()+" where YLTID = ? ");
		SQLBean sb = new SQLBean(sbuf.toString(), new String[]{map.get("YLTID")});
		super.update(sb);
	}


	@Override
	public JSONObject queryZdjg(Map<String, String> map) {
		StringBuffer sbuf = new StringBuffer();
		sbuf.append("select GLID from "+this.tb.getTableName()+" where YLTID = ? and YLJGID = ? and JGLX = '3'  and JLZT = '1'  ");
		SQLBean sb = new SQLBean(sbuf.toString(), new String[]{map.get("YLTID"),map.get("YLJGID")});
		return super.queryOne(sb);
	}


	@Override
	public JSONObject query(Map<String, String> map) {
		StringBuffer sbuf = new StringBuffer();
		sbuf.append("select * from "+this.tb.getTableName()+" where GLID = ?  ");
		SQLBean sb = new SQLBean(sbuf.toString(), new String[]{map.get("GLID")});
		return super.queryOne(sb);
	}
	
	@Override
	public void update(Map<String, String> map) {
		StringBuffer sbuf = new StringBuffer();
		sbuf.append("update "+this.tb.getTableName()+" set JLZT='0',QYZT='05'  where YLTID = ? and YLJGID = ? ");
		SQLBean sb = new SQLBean(sbuf.toString(), new String[]{map.get("YLTID"),map.get("YLJGID")});
		super.update(sb);
	}
	
}
